class Arg {
    constructor(arg) {
        this.date = arg.date ?? "2023-01-01";
        this.time = arg.time ?? "00:00:00.000.000";
        this.stream = arg.stream ?? '0';
        this.address = arg.address ?? 0x12341234;
        this.block = arg.block ?? 0xabcdabcd;
        this.size = arg.size ?? '65536';
        this.srcStream = arg.srcStream ?? '1';
        this.eventId = arg.eventId ?? '10';
        this.rtEvent = arg.rtEvent ?? "0x1010"
        this.streamId = arg.streamId ?? '0';
        // kernel name 规则：<kernel类型>_<计算节点名字>_<唯一id>
        this.name = arg.name ?? 'KernelType_DemoTestName_100';
    }
}
export function genAllocMem(arg) {
    arg = new Arg(arg);
    // 如果是申请输出内存，Kernel是AllocHbmMem，如果是ws内存，kernel是AllocBatchHbm
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 AllocHbmMem:[KernelTrace][${arg.name}][MEM]Alloc memory at stream ${arg.stream}, block 0x${arg.block.toString(16)}, address 0x${arg.address.toString(16)}, size ${arg.size}`;
}
export function genFreeMem(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 FreeMemory:[KernelTrace][${arg.name}][MEM]Free memory at stream ${arg.stream}, address 0x${arg.address.toString(16)}`;
}
export function genStartWandering(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 AccessMemory:[KernelTrace][${arg.name}][MEM]Memory wandering from stream ${arg.srcStream} to ${arg.stream}, address 0x${arg.address.toString(16)}`;
}
export function genLocalRecycle(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 FreeMemory:[KernelTrace][${arg.name}][MEM]Local-recycle memory at stream ${arg.stream}, address 0x${arg.address.toString(16)}`;
}
export function genBirthRecycle(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 FreeMemory:[KernelTrace][${arg.name}][MEM]Recycle memory at stream ${arg.stream}, address 0x${arg.address.toString(16)}`;
}
export function genRecycleSendEvent(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 SendEvent:[KernelTrace][${arg.name}][MEM]Send memory recycling event from stream ${arg.stream}, event id ${arg.eventId}, address 0x${arg.address.toString(16)}`;
}
export function genRecycleWaitEvent(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 WaitEvent:[KernelTrace][${arg.name}][MEM]Wait memory recycling event at stream ${arg.stream}, event id ${arg.eventId}, address 0x${arg.address.toString(16)}`;
}
export function genBorrowRecycle(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 FreeMemory:[KernelTrace][${arg.name}][MEM]Borrow-recycle memory at stream ${arg.stream}, address 0x${arg.address.toString(16)}`;
}
export function genMigrationSendEvent(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 SendEvent:[KernelTrace][${arg.name}][MEM]Send memory migration event from stream ${arg.stream}, event id ${arg.eventId}, address 0x${arg.address.toString(16)}`;
}
export function genMigrationWaitEvent(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 WaitEvent:[KernelTrace][${arg.name}][MEM]Wait memory migration event at stream ${arg.stream}, event id ${arg.eventId}, address 0x${arg.address.toString(16)}`;
}
export function genPoolExpand(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 Expand memory pool at stream ${arg.stream}, address 0x${arg.address.toString(16)}, size ${arg.size}`;
}
export function genPoolShrink(arg) {
    arg = new Arg(arg);
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 [MEM]Shrink memory pool at stream ${arg.stream}, address 0x${arg.address.toString(16)}, size ${arg.size}`;
}

export function genLinkStream(arg) {
    arg = new Arg(arg)
    return `[DEBUG] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 GetRtStreamById:[KernelTrace][${arg.name}]Get rts stream ${arg.stream} from logical stream ${arg.streamId}`;
}

export function genSendEvent(arg) {
    arg = new Arg(arg);
    return `[INFO] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 CallRtsSendEvent:[KernelTrace][${arg.name}]Sent event ${arg.eventId} RT event ${arg.rtEvent} from stream ${arg.stream}"`
}

export function genWaitEvent(arg) {
    arg = new Arg(arg);
    return `[INFO] GE(1600298,python3):${arg.date}-${arg.time} [file_name.cc:48] 1600298 CallRtsSendEvent:[KernelTrace][${arg.name}]Waited event ${arg.eventId} RT event ${arg.rtEvent} at stream ${arg.stream}"`
}

export const LOG_ALLOC_MEM_1 = genAllocMem({time: "10:40:20.220.150"});
export const LOG_FREE_MEM_1 = genFreeMem({time: "10:40:20.220.150"});
export const LOG_START_WANDERING_1 = genStartWandering({time: "10:40:20.220.150"});
export const LOG_LOCAL_RECYCLE_1 = genLocalRecycle({time: "10:40:20.220.150", stream: "1"});
export const LOG_BIRTH_RECYCLE_1 = genBirthRecycle({time: "10:40:20.220.150"});
export const LOG_RECYCLE_SEND_EVENT_1 = genRecycleSendEvent({time: "10:40:20.220.150", eventId: "11"});
export const LOG_RECYCLE_WAIT_EVENT_1 = genRecycleWaitEvent({time: "10:40:20.220.150", stream: "1", eventId: "11"});
export const LOG_RECYCLE_1 = genBorrowRecycle({time: "10:40:20.220.150", stream: "1"});
export const LOG_MIGRATION_SEND_EVENT_1 = genMigrationSendEvent({time: "10:40:20.220.150", stream: "1"});
export const LOG_MIGRATION_WAIT_EVENT_1 = genMigrationWaitEvent({time: "10:40:20.220.150"});
export const LOG_POOL_EXPAND_1 = genPoolExpand({time: "10:40:20.220.150", stream: "0xabcdabcd"});
export const LOG_POOL_SHRINK_1 = genPoolShrink({time: "10:40:20.220.150", stream: "0xabcdabcd"});
